
app:registClass("IMRoomController", "app.im.controllers.IMRoomController")
app:registClass("IMSimpleController", "app.im.controllers.IMSimpleController")
app:registClass("IMRecordController", "app.im.controllers.IMRecordController")
app:registClass("IMBubbleController", "app.im.controllers.IMBubbleController")
app:registClass("IMVoiceBtn", "app.im.views.renders.IMVoiceBtn")
app:registClass("IMVoiceRender", "app.im.views.renders.IMVoiceRender")

import(".imapi")
import(".models.IMModel")
local IMModel = import(".models.IMModel_share")
local IMMessage = import(".models.IMMessage")
local IMCommand = import(".models.IMCommand")

-- print("[im] isVaild ",im.isVaild())

app:registInst(IMModel.new())

app:registInst(app:getClass("IMRoomController").new({type="world", zOrder=SceneZOrder.chatRoomUiZOrder}))
app:registInst(app:getClass("IMRecordController").new({type="world", zOrder=SceneZOrder.chatRoomUiZOrder+1}))
app:registInst(app:getClass("IMSimpleController").new({type="world", zOrder=SceneZOrder.chatUiZOrder}))
app:registInst(app:getClass("IMBubbleController").new({}))

IMCommand.new()

local model = app:getInst("IMModel")

app.session:on("action.S2C_UserGetExp",function(msg)
	UD:updateExpRewardLv(msg.rewardLevel)
	model:addSystemMsg("gotexp", msg.exp)
end)

app.session:on("pb_chat.S2C_InterChat",function(msg)
	model:onRecvMessages({msg})
end)

app.session:on("pb_chat.S2C_MultipleMsg",function(msg)
	model:onRecvMessages(msg.msg)
end)

-- 删除指定玩家的发言
app.session:on("pb_chat.S2C_ClearMessage",function(msg)
	-- print("S2C_ClearMessage---------->>>>", msg.uid)
	model:onClearMessage(msg.uid)
end)

app.session:on("chat.CSN_ChatMessage", handler(model, model.recvGMCommand))

app.session:on("systemlog.S2C_SystemLog", function(ret)
	-- dump(ret, "systemlog.S2C_SystemLog")
	model:addSystemMsg(ret.id, ret.values)
	local text = L(ret.id)
	if ret.values then
		text = string.format(text, unpack(ret.values))
	end
	app:popMessage(text, {pushToast=true})
end)

app.session:on("pb_server.S2C_Announce",function(msg)
	-- dump(msg, "server.S2C_Announce")
	model:updateAnnounce(msg)
end)